package com.zsw.customer1c.controller;

import com.zsw.customer1c.service.testServiceProducer1;
import com.zsw.customer1c.service.testServiceProducer2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 使用fegin 微服务之间的通信
 */
@RestController
public class testController {

    //注入外部接口
    @Autowired
    testServiceProducer1 testServiceProducer1;

    @Autowired
    testServiceProducer2 testServiceProducer2;


    private String message = "当前的消费端是customer1rabbion,启用负载均衡,端口号：7000";

    @RequestMapping("1/hi/{id}")
    public String hi1(@PathVariable String id) {
        System.out.println("调用的服务端是，哈哈，服务名是serviceproducer1");
        return message + ">>>" + testServiceProducer1.hi(id);
    }

    @RequestMapping("1/client")
    public String test1() {
        System.out.println("调用的服务端是，哈哈，服务名是serviceproducer1");
        return message + ">>>" + testServiceProducer1.test();
    }

    @RequestMapping("2/hi/{id}")
    public String hi2(@PathVariable String id) {
        System.out.println("调用的服务端是，哈哈，服务名是serviceproducer2");
        return message + ">>>" + testServiceProducer2.hi(id);
    }

    @GetMapping("2/client")
    public String test2() {
        System.out.println("这个是从另一个服务调用的，哈哈，服务名是serviceproducer2");
        return message + ">>>" + testServiceProducer2.test();
    }
}
